<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body {
            width: 50%;
            height: 100vh;
            margin: 0 auto;
            background-color: #abefe9;
            text-align: center;
        }


        hr {
            background-color: red;
            height: 1px;
            border: 0;
        }

        .s1 {
            display: block;
            width: 200px;
            height: 200px;
            background-color: #FFCCCC;
        }

        .d1 {
            display: inline;
            /* width: 200px;
            height: 200px; */
            background-color: #FFCCCC;
            border: 2px #bfa solid;
        }

        .d2 {
            display: inline-block;
            width: 160px;
            height: 160px;
            border: 2px #bfa solid;
            background-color: #FFCCCC;
        }

        .d3 {
            display: inline-block;
            border: 2px #bfa solid;
            background-color: #FFCCCC;
            border-radius: 5px;
            padding: 5px;
            text-align: center;
            cursor: pointer;
            user-select: none;
            width: 120px;
        }
    </style>
    <script>
        function toDisplay(obj) {
            obj.style.display = "none"
        }
        function toVisibility(obj) {
            obj.style.visibility = "hidden"
        }

        function toChangeDisplay(id) {
            document.getElementById(id).style.display = "inline-block"
        }

        function toChangeVisibility(id) {
            document.getElementById(id).style.visibility = "visible"

        }
    </script>
</head>

<body>
    <hr>
    <span class="s1">
        span元素
        <hr>
        display: block;将元素转换为块元素
    </span>
    <hr>
    <div class="d1">
        div元素
    </div>
    <div class="d1">
        display: inline;将元素变成内联元素
    </div>
    <hr>
    <div class="d2">
        div元素
        <hr>
    </div>
    <div class="d2">
        display: inline-block;
        <hr>
        表现为内联元素但可以设置宽高
    </div>
    <hr>
    <div class="d3" id="js1" onclick="toDisplay(this)">
        display:none
        <hr>
        点击消失
    </div>
    <div class="d3" onclick="toChangeDisplay('js1')">
        点击出现
    </div>
    <hr>
    <div class="d3" id="js2" onclick="toVisibility(this)">
        visibility:hidden
        <hr>
        点击消失
    </div>
    <div class="d3" onclick="toChangeVisibility('js2')">
        点击出现
    </div>

</body>

</html>